package com.shawn.integeration.common.model.http;

import lombok.Getter;
import lombok.Setter;

/**
 * Http 请求返回
 *
 * @author: shawn
 * @Date: 2024/2/19 16:40
 * @Version 1.0.0
 */
@Getter
@Setter
public class HttpRes <T>{
    private boolean success;

    private String msg;

    private T data;

    public HttpRes(boolean success, String msg, T data) {
        this.success = success;
        this.msg = msg;
        this.data = data;
    }

    public HttpRes(boolean success, String msg) {
        this(success, msg,null);
    }


    public static <T> HttpRes<T> error(String msg) {
        return new HttpRes<>(false, msg);
    }

    public static <T> HttpRes<T> success(T data) {
        return new HttpRes<>(true, "请求成功",data);
    }
}
